<template>
  <div>
    商品名称 <input type="text"  v-model="name">
    商品价格 <input type="text" v-model="price">
    店主 <select name="" id="" v-model="userid">
    <option :value="i.id" v-for="i in userlist">{{i.username}}</option>
  </select>
    商品图片 <input type="file" id="imgs">
    <button @click="add" >添加</button>
  </div>
</template>

<script>
export default {
  name: "day1019_add",
  data() {
    return {
      name:'',
      price:'',
      userlist:[],
      userid:''
    }
  },
  methods: {
    add(){
      let pic = document.getElementById('imgs').files[0]

      let form = new FormData
      form.append('name',this.name)
      form.append('price',this.price)
      form.append('userid',this.userid)
      form.append('img',pic)

      this.$axios.post('user/shopuser/',form).then(res=>{

      })
    },
    get_user(){
      this.$axios.get('user/shopuser/').then(res=>{
        this.userlist =res.data.list
      })
    },


    },

  mounted() {
    this.get_user()
  }

}
</script>

<style scoped>

</style>
